<template>
  <div>

    <div class="imageBox">
      <van-image
      class="img"
        round
        width="4rem"
        height="4rem"
        src="https://img01.yzcdn.cn/vant/cat.jpeg"
      />
      <div>
        <p>{{mobile}}</p>
        <p>{{nick_name}}</p>
      </div>
    </div>

    <button @click="logout">退出登录</button>
  </div>
</template>

<script>
import router from '@/router'
import { delToken } from '@/utils/local'
import { userInfo } from '@/api/user'
export default {
  name: 'MyView',
  data () {
    return {
      mobile: '',
      nick_name: ''
    }
  },
  created () {
    this.render()
  },
  methods: {
    logout () {
      router.push('/login')
      delToken()
    },
    async render () {
      const res = await userInfo()
      console.log(res)
      this.mobile = res.data.userInfo.mobile
      this.nick_name = res.data.userInfo.nick_name
    }
  }
}
</script>

<style scoped>
.imageBox{
  padding: 40px 0 0;

}
.img{
  margin: 0 15px;
}
</style>
